from datetime import date


def calculate_age(born, calculate_data=date.today()):
    try:
        birthday = born.replace(year=calculate_data.year)
    except ValueError:  # raised when birth date is February 29 and the current year is not a leap year
        birthday = born.replace(year=calculate_data.year, month=born.month + 1, day=1)
    if birthday >= calculate_data:
        return calculate_data.year - born.year
    else:
        return calculate_data.year - born.year + 1


def average(listTemp, step):  # 列表根据具体数据均分
    new_list = []
    for i in range(0, len(listTemp), step):
        new_list.append(listTemp[i:i + step])
    return new_list
